﻿using System;
using System.Collections.Generic;

namespace Leaf.NetCore.Cache
{
    /// <summary>
    /// 版本：1.0
    /// 描述：定义缓存接口
    /// 日期：2018-11-5 17:48:05
    /// 创建人：王志海
    /// Copyright (c) 2015-2018 首溯科技有限公司
    /// </summary>
    public interface ICache
    {
        /// <summary>
        /// 读取缓存
        /// </summary>
        /// <param name="cacheKey">键</param>
        /// <returns></returns>
        T GetCache<T>(string cacheKey) where T : class;
        /// <summary>
        /// 写入缓存
        /// </summary>
        /// <param name="cacheKey">键</param>
        /// <param name="cacheValue">对象数据</param>

        void SetCache<T>(string cacheKey, T cacheValue) where T : class;
        /// <summary>
        /// 写入缓存
        /// </summary>
        /// <param name="cacheKey">键</param>
        /// <param name="cacheValue">对象数据</param>
        /// <param name="expireTime">到期时间</param>
        void SetCache<T>(string cacheKey, T cacheValue, DateTime? expireTime) where T : class;
        /// <summary>
        /// 移除指定数据缓存
        /// </summary>
        /// <param name="cacheKey">键</param>
        void RemoveCache(string cacheKey);
        /// <summary>
        /// 移除全部缓存
        /// </summary>
        void RemoveCache();

        /// <summary>
        /// 获取所有的Key
        /// </summary>
        /// <returns></returns>
        List<string> GetKeys();
    }
}
